class Solution(object):
    def checkOverlap(self, radius, xCenter, yCenter, x1, y1, x2, y2):
        if x1 <= xCenter <= x2 and y1 <= yCenter <= y2:
            return True
        if (x1 - xCenter) ** 2 + (y1 - yCenter) ** 2 <= radius ** 2 or (x2 - xCenter) ** 2 + (y1 - yCenter) ** 2 <= radius ** 2 or (x1 - xCenter) ** 2 + (y2 - yCenter) ** 2 <= radius ** 2 or (x2 - xCenter) ** 2 + (y2 - yCenter) ** 2 <= radius ** 2:
            return True
        if abs(x1 - xCenter) <= radius:
            d = abs(x1 - xCenter)
            r = (radius ** 2 - d ** 2) ** 0.5
            if y1 <= yCenter - r <= y2 or y1 <= yCenter + r <= y2:
                return True
        if abs(x2 - xCenter) <= radius:
            d = abs(x2 - xCenter)
            r = (radius ** 2 - d ** 2) ** 0.5
            if y1 <= yCenter - r <= y2 or y1 <= yCenter + r <= y2:
                return True
        if abs(y1 - yCenter) <= radius:
            d = abs(y1 - yCenter)
            r = (radius ** 2 - d ** 2) ** 0.5
            if x1 <= xCenter - r <= x2 or x1 <= xCenter + r <= x2:
                return True
        if abs(y2 - yCenter) <= radius:
            d = abs(y2 - yCenter)
            r = (radius ** 2 - d ** 2) ** 0.5
            if x1 <= xCenter - r <= x2 or x1 <= xCenter + r <= x2:
                return True
        return False

data = Solution()
# print(data.checkOverlap(1, 0, 0, 1, -1, 3, 1))
# print(data.checkOverlap(1, 0, 0, -1, 0, 0, 1))
# print(data.checkOverlap(1, 1, 1, -3, -3, 3, 3))
# print(data.checkOverlap(1, 1, 1, 1, -3, 2, -1))
# print(data.checkOverlap(3, 4, 1, 3, 3, 8, 5 ))
print(data.checkOverlap(18, 11, 19, 7, 12, 10, 20 ))